home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / examples / trans.lsp < prev    next >
Encoding:
Lisp/Scheme  |  1991-10-06  |  2.9 KB  |  85 lines

  1. ; -*-Lisp-*-
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ; File:         trans.lsp
  5. ; RCS:          $Header: trans.lsp,v 1.4 91/10/05 19:04:49 mayer Exp $
  6. ; Description:  Tests of Xt trnaslation, accelerator facilies. Also test
  7. ;               winterp's "Lisp()" action, which allows you to call the
  8. ;               lisp evaluator from a translation/accelerator table.
  9. ; Author:       Niels Mayer, HPLabs
  10. ; Created:      Fri Nov 24 20:16:35 1989
  11. ; Modified:     Sat Oct  5 19:04:18 1991 (Niels Mayer) mayer@hplnpm
  12. ; Language:     Lisp
  13. ; Package:      N/A
  14. ; Status:       X11r5 contrib tape release
  15. ;
  16. ; WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  17. ; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  18. ;
  19. ; Permission to use, copy, modify, distribute, and sell this software and its
  20. ; documentation for any purpose is hereby granted without fee, provided that
  21. ; the above copyright notice appear in all copies and that both that
  22. ; copyright notice and this permission notice appear in supporting
  23. ; documentation, and that the name of Hewlett-Packard and Niels Mayer not be
  24. ; used in advertising or publicity pertaining to distribution of the software
  25. ; without specific, written prior permission.  Hewlett-Packard and Niels Mayer
  26. ; makes no representations about the suitability of this software for any
  27. ; purpose.  It is provided "as is" without express or implied warranty.
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29.  
  30. ;;
  31. ;; Test use of 'Lisp' action to call lisp evaluator through translation
  32. ;; or accelerator table entry:
  33. ;;
  34.  
  35. (setq trans
  36.       (XT_PARSE_TRANSLATION_TABLE 
  37.        "Ctrl<Key>L: Lisp(quack action_widget action_xevent) \
  38. Ctrl<Key>K: Lisp(print 'ctrl-key-k-hit)"
  39.        ))
  40.  
  41. (setq accel
  42.       (XT_PARSE_ACCELERATOR_TABLE
  43.        "Ctrl<Key>L: Lisp(quack action_widget action_xevent) \
  44. Ctrl<Key>K: Lisp(print 'ctrl-key-k-hit)"
  45.        ))
  46.  
  47. (defun quack (w e)
  48.   (format T "widget=~A; event=~A\n" w e)
  49. )
  50.  
  51. (setq pb_w
  52.       (send XM_PUSH_BUTTON_WIDGET_CLASS :new :managed "pb_w" rc_w
  53.         ))
  54. (send pb_w :augment_translations trans)
  55. (send pb_w :override_translations trans)
  56. (send pb_w :augment_translations "Ctrl<Key>A: Lisp(print 'ctrl-key-a-hit)")
  57. (send pb_w :uninstall_translations)    ;this completely disables widget!
  58.  
  59.  
  60. ;;
  61. ;; Accelerators
  62. ;;
  63. (send rc_w :set_values
  64.       :xmn_accelerators "Ctrl<Key>A: Lisp(print 'ctrl-key-a-hit)"
  65.       )
  66.  
  67. (progn                    ;install accelerator on  rc_w
  68.                     ;onto each pushbuttonwe create
  69.   (setq pb_w
  70.     (send XM_PUSH_BUTTON_WIDGET_CLASS :new :managed "pb_w" rc_w
  71.           ))
  72.   (send pb_w :install_all_accelerators rc_w)
  73.   )
  74.  
  75. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  76.  
  77. (setq te_w (send XM_TEXT_WIDGET_CLASS :new :managed :scrolled rc_w
  78.          :XMN_EDIT_MODE :MULTI_LINE_EDIT
  79.          :XMN_HEIGHT 400
  80.          :XMN_WIDTH  300
  81.          ))
  82. (send te_w :override_translations
  83.       "Ctrl<Key>A: beginning-of-line()\
  84.        <Key>Return: newline-and-indent()")
  85.